package com.digitalchina.lxnsy.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.digitalchina.lxnsy.entity.CityTypePriceVO;
import com.digitalchina.lxnsy.viewholder.CityTypePriceViewHolder;
import com.digitalchina.lxnsy.viewholder.CityTypeViewHolder;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

import java.security.InvalidParameterException;

public class CityWithTypeAdapter extends RecyclerArrayAdapter<Object> {
    public static final int TYPE_CITY = 1;
    public static final int TYPE_TYPE = 2;
    public CityWithTypeAdapter(Context context) {
        super(context);
    }

    @Override
    public int getViewType(int position) {
        if(getItem(position) instanceof CityTypePriceVO){
            return TYPE_CITY;
        }else if (getItem(position) instanceof CityTypePriceVO.CityDataListBean){
            return TYPE_TYPE;
        }
        return 0;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType){
            case TYPE_TYPE:
                return new CityTypePriceViewHolder(parent);
            case TYPE_CITY:
                return new CityTypeViewHolder(parent);
            default:
                throw new InvalidParameterException();
        }
    }
}
